<div id="product-tab-<?php echo $module; ?>" class="product-tab">
<!--<div id="tabs-<?php echo $module; ?>" class="htabs">-->
<ul id="tabs-<?php echo $module; ?>" class="tabs">
<?php if($featured_products && $featured_products_status == 1){ ?>
	<li><a href="#tab-featured-<?php echo $module; ?>"><?php echo $tab_featured; ?></a></li>
<?php } ?>
<?php if($latest_products && $latest_products_status == 1){ ?>
	<li><a href="#tab-latest-<?php echo $module; ?>"><?php echo $tab_latest; ?></a></li>
<?php } ?>
<?php if($bestseller_products && $bestseller_products_status == 1){ ?>
	<li><a href="#tab-bestseller-<?php echo $module; ?>"><?php echo $tab_bestseller; ?></a></li>
<?php } ?>
<?php if($special_products && $special_products_status == 1){ ?>
  	<li><a href="#tab-special-<?php echo $module; ?>"><?php echo $tab_special; ?></a></li>
<?php } ?>
</ul>
<?php if($featured_products && $featured_products_status == 1){ ?>
<div id="tab-featured-<?php echo $module; ?>" class="tab_content">
<div class="box-product">
  <div class="flexslider featured_carousel_tab">
      <ul class="slides">
        <?php foreach ($featured_products as $product) { ?>
        <li>
          <div class="slide-inner">
            <?php if ($product['thumb']) { ?>
            <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
            <?php } ?>
            <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
            <?php if ($product['price']) { ?>
            <div class="price">
              <?php if (!$product['special']) { ?>
              <?php echo $product['price']; ?>
              <?php } else { ?>
              <span class="price-old"><?php echo $product['price']; ?></span><span class="price-new"><?php echo $product['special']; ?></span>
              <?php } ?>
            </div>
            <?php } ?>
            <div class="cart">
              <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
            </div>
            <?php if ($product['rating']) { ?>
            <div class="rating"><img src="catalog/view/theme/moderns/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
            <?php } ?>
            <div class="clear"></div>
          </div>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
<?php } ?>
<?php if($latest_products && $latest_products_status == 1){ ?>
<div id="tab-latest-<?php echo $module; ?>" class="tab_content">

<div class="box-product">
  <div class="flexslider latest_carousel_tab">
      <ul class="slides">
        <?php foreach ($latest_products as $product) { ?>
        <li>
          <div class="slide-inner">
            <?php if ($product['thumb']) { ?>
            <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
            <?php } ?>
            <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
            <?php if ($product['price']) { ?>
            <div class="price">
              <?php if (!$product['special']) { ?>
              <?php echo $product['price']; ?>
              <?php } else { ?>
              <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
              <?php } ?>
            </div>
            <?php } ?>
            <div class="cart">
              <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
            </div>
            <?php if ($product['rating']) { ?>
            <div class="rating"><img src="catalog/view/theme/moderns/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
            <?php } ?>
            <div class="clear"></div>
          </div>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
<?php } ?>
<?php if($bestseller_products && $bestseller_products_status == 1){ ?>
<div id="tab-bestseller-<?php echo $module; ?>" class="tab_content">
<div class="box-product">
  <div class="flexslider bestseller_carousel_tab">
      <ul class="slides">
        <?php foreach ($bestseller_products as $product) { ?>
        <li>
          <div class="slide-inner">
          <?php if ($product['thumb']) { ?>
          <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
          <?php } ?>
          <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
          <?php if ($product['price']) { ?>
          <div class="price">
            <?php if (!$product['special']) { ?>
            <?php echo $product['price']; ?>
            <?php } else { ?>
            <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
            <?php } ?>
          </div>
          <?php } ?>
          <div class="cart">
            <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
          </div>
          <?php if ($product['rating']) { ?>
          <div class="rating"><img src="catalog/view/theme/moderns/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
          <?php } ?>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
<?php } ?>
<?php if($special_products && $special_products_status == 1){ ?>
<div id="tab-special-<?php echo $module; ?>" class="tab_content">
<div class="box-product">
  <div class="flexslider special_carousel_tab">
      <ul class="slides">
        <?php foreach ($special_products as $product) { ?>
        <li>
          <div class="slide-inner">
            <?php if ($product['thumb']) { ?>
            <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
            <?php } ?>
            <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
            <?php if ($product['price']) { ?>
            <div class="price">
              <?php if (!$product['special']) { ?>
              <?php echo $product['price']; ?>
              <?php } else { ?>
              <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
              <?php } ?>
            </div>
            <?php } ?>
            <div class="cart">
              <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
            </div>
            <?php if ($product['rating']) { ?>
            <div class="rating"><img src="catalog/view/theme/moderns/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
            <?php } ?>
            <div class="clear"></div>
          </div>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
<?php } ?>
</div>

<script type="text/javascript">
(function() {
 
  // store the slider in a local variable
  var $window = $(window),
      flexslider;
 
  // tiny helper function to add breakpoints
  function getGridSize() {
    return (window.innerWidth < 320) ? 1 :
		   (window.innerWidth < 600) ? 2 :
		   (window.innerWidth < 800) ? 3 :
           (window.innerWidth < 900) ? 4 : 4;
  }
  $window.load(function() {
    $('#product-tab-<?php echo $module; ?> .featured_carousel_tab, #product-tab-<?php echo $module; ?> .latest_carousel_tab, #product-tab-<?php echo $module; ?> .bestseller_carousel_tab, #product-tab-<?php echo $module; ?> .special_carousel_tab').flexslider({
      animation: "slide",
      animationLoop: false,
	  slideshow: false,
      itemWidth: 210,
      minItems: getGridSize(), // use function to pull in initial value
      maxItems: getGridSize(), // use function to pull in initial value
	  start: function(){
		  $("#product-tab-<?php echo $module; ?> .tab_content").addClass("deactive");
		  $("#product-tab-<?php echo $module; ?> .tab_content:first").removeClass("deactive"); //Show first tab content
		  } });
  });
  
}());

$(document).ready(function() {
    //Default Action
    $("ul#tabs-<?php echo $module; ?> li:first").addClass("active").show(); //Activate first tab
    //On Click Event
    $("ul#tabs-<?php echo $module; ?> li").click(function() {
        $("ul#tabs-<?php echo $module; ?> li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        //$("#product-tab-<?php echo $module; ?> .tab_content").removeClass("deactive"); //Hide all tab content
		$("#product-tab-<?php echo $module; ?> .tab_content").hide(); 
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });
});
</script>